package cn.life.money.controller;

import cn.life.common.pojo.CommonResult;
import cn.life.money.req.AddAccountItemReq;
import cn.life.money.req.CommonIdReq;
import cn.life.money.service.biz.MoneyBizService;
import cn.life.money.vo.AccountItemVO;
import cn.life.money.vo.MoneyAccountVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/money/core")
@Validated
public class MoneyController {

    @Resource
    private MoneyBizService moneyBizService;

    /**
     * 获取所有的账户
     *
     * @author dongli
     * @since 2024/9/24 15:51
     */
    @GetMapping("/getAllAccount")
    public CommonResult<List<MoneyAccountVO>> getAllAccount() {
        return CommonResult.success(moneyBizService.getAllAccount());
    }

    /**
     * 添加账户
     *
     * @author dongli
     * @since 2024/9/24 15:57
     */
    @PutMapping("/addAccountItem")
    public CommonResult<String> addAccountItem(AddAccountItemReq req) {
        return CommonResult.success(moneyBizService.addAccountItem(req));
    }

    /**
     * 获取账户的详细信息
     *
     * @author dongli
     * @since 2024/9/24 16:17
     */
    @GetMapping("/getAccountItem")
    public CommonResult<AccountItemVO> getAccountItem(CommonIdReq req) {
        return CommonResult.success(moneyBizService.getAccountItem(req));
    }
}
